<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link href="../css/video.css"  rel="stylesheet" />
		<link href="../css/layui.css" rel="stylesheet"  />
	</head>

<style>
	*{
		font-family:PingFang-SC-Bold;
	}
	.mui-bar-nav{
		box-shadow: none;
		background: #FFFFFF;
		border-bottom: 1px solid rgba(248,248,248,1);
	}
	
	.mui-title{
		font-weight:bold;
color:rgba(51,51,51,1);
	}
	.mui-content{
		position: relative;
		width: 100%;
		background: #FFFFFF;
		height: 100%;
		padding-bottom: 20px;
		display: inline-block;
	}
	.shipin{
		position: relative;
		float: left;
		width: 100%;
		    background: #ffffff;
		padding:  0  15px;
		box-sizing: border-box;
	}
	.shipin>div:nth-child(1){
		position: relative;
		 float: left;
		 width: 100%;
		 text-align: center;
	}
	
	
	.shipin>div:nth-child(1)>video{
		width: 100%;
		height: 100%;
	}
	.shipin>div:nth-child(2){
		position: relative;
		float: left;
		width: 100%;
		text-align: center;
		font-size:15px;
        font-weight:500;
        color:rgba(51,51,51,1);
	}
	.hang{
		position: relative;
		float: left;
		width: 100%;
		height:10px;
		background: rgba(248,248,248,1);;
	}
	
	.fenlei{
		position: relative;
		float: left;
		width: 100%;
		background: #FFFFFF;
		padding: 0  15px;
		height: 55px;
	}
	.fenlei>div{
		position: relative;
		float: left;
		width: 130px;
		height: 100%;
		line-height: 55px;
		 font-size:16px;
        font-family:PingFang-SC-Bold;
        font-weight:bold;
        color:rgba(51,51,51,1);
	}
	.mui-btn-block{
		position: relative;
		float: right;
		width: 135px!important;
		height: 55px!important;
		text-align: right;
		 font-size:14px;
         font-weight:500;
         color:rgba(205,205,205,1)!important;  
		 line-height: 55px!important;
		 padding: 0 0 !important;
		 padding-left: 20px!important;
		 border: none;
	}
	
	.shipinname{
		position: relative;
		float: left;
		width: 100%;
		height: 55px;
		line-height: 55px;
		padding: 0 15px;
		box-sizing: border-box;
		border: none;
		font-size:15px;
        font-weight:500;
        color:rgba(153,153,153,1);
		background: #FFFFFF;
		border-bottom: 2px solid rgba(248,248,248,1);
	}
	#textarea{
		border: none;
		padding: 5px 15px;
		box-sizing: border-box;
		line-height: 22px;
		font-size: 15px;
		border: 1px  solid  rgba(248,248,248,1);
	}
		.tupian{
		position: relative;
		float: left;
		width: 100%;
		background: #FFFFFF;
		padding: 0px  15px;
		padding-bottom: 10px;
		box-sizing: border-box;
	}
	.tupian>.tupians{
		position: relative;
	      width: 100%;
		float: left;
	}
	.tupian>.tupians>div{
		width: calc((100% - 36px) / 3);
		height: 107px;
		margin-left: 12px;
		position: relative;
		float: left;
		margin-top: 10px;
	}
	.tupian>.tupians>div>.danimg{
		width: 100%;
		height: 107px;
	}
	
	.tupian>.tupians>div>.danimg2{
		position: absolute;
		right:0px;
		top: 0px;
		width: 18px;
		height: 18px;
		z-index: 10;
	}
	.huqueren{
		position: relative;
		float: left;
		width: 100%;
		height: 43px;
		background: #FFFFFF;
	}
	.mui-btnss{
		position: relative;
		float: left;
		width: calc(100% - 30px);
		height: 43px;
		margin-left: 15px;
		box-sizing: border-box;
		border: none;
		text-align: center;
	color:rgba(255,255,255,1);
		background:linear-gradient(180deg,rgba(252,126,119,1) 0%,rgba(254,96,93,1) 100%);
      box-shadow:0px 5px 8px 0px rgba(254, 95, 99, 0.35);
border-radius:43px;
	}
	options{
		font-size: 14px;
	}
		.shangchuan{
		width: 30%;
		height: 107px;
		margin-left: 12px;
		position: relative;
		float: left;
		margin-top: 10px;
	}
	input[type=text]{
		border: none;
		margin-bottom:0px;
	}
	
	*{
		font-family:PingFang-SC-Bold;
	}
	      .mui-bar{ box-shadow: none; background: white; height:50px;}
			.mui-bar .mui-icon{ margin-top:4px; font-size:28px; color: #999999; }
			.mui-bar-nav.mui-bar .mui-icon{padding-left:5px;}
			.mui-bar .mui-title{margin-top:6px;color: #2f2f2f; font-weight: normal;}
			.more{ margin-top: 16px; margin-right: 5px;}
			.mui-bar:after
	 {
	position: absolute;
	right: 0;
	 bottom: 0;
	left: 0;
	height: 1px;
	content: '';
	-webkit-transform: scaleY(.5);
	transform: scaleY(.5);
	background-color:#dadada; 	
	    		 }
	body{ background: white; }
	.mui-content{ padding-bottom:40px; display: inline-block; margin-top: 10px;background: white; }
	.user_txt{padding-left: 1rem; height: 25px; margin: 0px; margin-bottom: 20px;}
	.news_title{
		font-size: 1.4rem;
	    line-height: 1.5;
	    font-weight:500;
	    padding-left: 1rem;
	    padding-right: 1rem;
	    margin-top: .9rem;
	    margin-bottom: .3rem;
	    }
	.user_img{ width: 25px; height: 25px; border-radius: 25px; margin-right: 5px;}
	.user_name,.news_time{ position: relative; top: -8px; font-size: 12px;}
	.news_time{  margin-left: 10px;}
	.text_dome{ padding: 10px;}
	.text_dome b{ color: #000000; font-size: 16px;}
	
	#openvideo{ height: 50px; line-height: 50px; color:white; text-align: center; position: fixed; z-index:110; bottom: 0px; width: 100%; background-color:#000000;}
	.mui-video-Container {
		background-color: #FFFFFF;
		overflow: hidden;
		margin: 10px;
		padding: 0px;
	}
	
	.mui-video-Container .mui-video-full {
		position: relative;
		overflow: hidden;
	}
	
	.mui-video-Container video {
		width: 100%;
		background-color: #000000;
	}
	
	.mui-video-Container video[ishivideo="true"]::-webkit-media-controls {
		display: none !important;
	}
	
	.mui-video-Container video[ishivideo="true"]::-moz-media-controls {
		display: none !important;
	}
	
	.mui-video-Container video[ishivideo="true"]::media-controls {
		display: none !important;
	}
	
	.mui-video-Container .icon {
		width: 1em;
		height: 1em;
		vertical-align: -0.15em;
		fill: currentColor;
		overflow: hidden;
		font-size: 20px;
		position: relative;
		top: 1px;
	}
	
	.mui-video-Container .rprogress {
		position: absolute;
		left: 0px;
		top: 0px;
		bottom: 0px;
		right: 0px;
		margin: auto;
		width: 60px;
		height: 60px;
		text-align: center;
		line-height: 60px;
		display: none;
	}
	
	.mui-video-Container .rprogress .ladtit {
		color: white;
		font-size: 14px;
	}
	
	.mui-video-Container .rschedule {
		background-color: rgba(0, 0, 0, 0);
		border: 3px solid rgba(0, 183, 229, 0.9);
		opacity: .9;
		border-left: 5px solid rgba(0, 0, 0, 0);
		border-right: 5px solid rgba(0, 0, 0, 0);
		border-radius: 50px;
		box-shadow: 0 0 15px #2187e7;
		width: 46px;
		height: 46px;
		position: absolute;
		left: 50%;
		top: 50%;
		margin-left: -23px;
		margin-top: -23px;
		-webkit-animation: spin 1s infinite linear;
		animation: spin 1s infinite linear;
	}
	
	@-webkit-keyframes spin {
		0% {
			-webkit-transform: rotate(0deg);
		}
	
		100% {
			-webkit-transform: rotate(360deg);
		}
	}
	
	@keyframes spin {
		0% {
			transform: rotate(0deg);
		}
	
		100% {
			transform: rotate(360deg);
		}
	}
	
	/*横条样式*/
	.mui-video-Container input[type=range] {
		-webkit-appearance: none;
		/*清除系统默认样式*/
		width: 100%;
		background: -webkit-linear-gradient(#40CEA8, #40CEA8) no-repeat, #fff;
		/*设置左边颜色为#61bd12，右边颜色为#ddd*/
		background-size: 0% 100%;
		/*设置左右宽度比例*/
		height: 3px;
		/*横条的高度*/
	}
	
	/*拖动块的样式*/
	.mui-video-Container input[type=range]::-webkit-slider-thumb {
		-webkit-appearance: none;
		/*清除系统默认样式*/
		height: 13px;
		/*拖动块高度*/
		width: 13px;
		/*拖动块宽度*/
		background: #fff;
		/*拖动块背景*/
		border-radius: 50%;
		/*外观设置为圆形*/
		/* border: solid 1px #ddd;*/
		/*设置边框*/
	}
	
	.mui-video-Container .mui-pay_ico {
		z-index: 2;
		width: 80px;
		text-align: center;
		height: 80px;
		margin: auto;
		position: absolute;
		top: 0;
		left: 0;
		bottom: 0;
		right: 0;
	}
	
	.mui-video-Container .mui-pay_ico .icon {
		font-size: 52px;
		color: white;
	}
	
	.mui-video-Container .mui-time-current {
		width: 46px;
		float: left;
		text-align: right;
		display: inline-block;
		color: white;
		font-size: 14px;
	}
	
	.mui-video-Container .mui-time-total {
		width: 78px;
		text-align: center;
		color: white;
		display: inline-block;
		font-size: 14px;
	}
	
	.mui-video-Container .mui-time-total .icon {
		font-size: 28px;
		color: white;
	}
	
	.mui-video-Container .mui-time-cout {
		float: left;
		margin-top: -5px;
	}
	
	.mui-video-Container .mui-quanping {
		margin-top: 6px;
		margin-left: 3px;
		position: absolute;
		right: 0px;
		z-index: 10;
	}
	
	.mui-video-Container .mui-videoControls {
		height: 40px;
		width: 100%;
		line-height: 40px;
		background-color: rgba(0, 0, 0, 0.5);
		position: absolute;
		z-index: 9;
		bottom: 0px;
		overflow: hidden;
	}
	
	.mui-video-Container .mui-progressWrap {
		height: 20px;
		width: 100%;
		position: absolute;
		top: 18px;
		left: 55px;
	}
	
	.mui-video-Container .mui-progressWrap .mui-wrap-right {
		position: absolute;
		width: 100%;
		padding-right: 148px;
	}
	
	.mui-video-Container .mui-full-back {
		position: absolute;
		z-index: 2;
		display: none;
	}
	
	.mui-video-Container .mui-full-back .icon {
		font-size: 26px;
		color: white;
		left: 15px;
		top: 5px;
	}
	
	.mui-video-Container .mui-full-back .vtitle {
		color: white;
		margin-left: 15px;
		position: relative;
		top: 4px;
		font-size: 15px;
	}
	
	.mui-video-Container .v_left,
	.mui-video-Container .b_right {
		position: absolute;
		width: 50%;
		height: 100%;
		z-index: 1;
	}
	
	.mui-video-Container .b_right {
		right: 0px;
	}
	
	.mui-video-Container .ptime {
		position: absolute;
		z-index: 2;
		left: 0px;
		text-align: center;
		display: none;
		top: 0px;
		bottom: 0px;
		right: 0px;
		margin: auto;
		border-radius: 3px;
		background-color: rgba(0, 0, 0, 0.6);
		height: 40px;
		width: 120px;
		line-height: 40px;
		color: white;
	}
	.text_dome{
		text-indent: 2em;
	}
	
	.dianzan{
		position: relative;
		float: left;
		width: 100%;
		height: 60px;
		padding: 8px 10px;
		box-sizing: border-box;
		border-bottom: 1px solid rgba(235,235,235,1);
	}
	
	.dianzan>div{
		position: relative;
	    width: 70px;
		height: 44px;
		float: left;
	
	}
	.dianzan>div>img{
		width: 22px;
		height: 22px;
		position: relative;
		float: left;
		margin-top: 11px;
	}
	
	.dianzan>div>span{
		padding: 0 5px;
		box-sizing: border-box;
		font-size:13px;
	    font-weight:500;
	    color:rgba(254,97,94,1);
	    line-height:44px;
	}
	
	.pinglun{
		position: relative;
		float: left;
		width: 100%;
		padding: 10px 10px;
		box-sizing: border-box;
		padding-bottom: 80px;
	}
	.pinglun>div:nth-child(1){
		position: relative;
		float: left;
		width: 100%;
	} 
	.pinglun>div:nth-child(1)>span:nth-child(1){
	  position: relative;
	  float:left;
	  width: 40px;
	  line-height: 36px;  
	 font-size:13px;
	font-weight:500;
	color:rgba(102,102,102,1);
	}
	.pinglun>div:nth-child(1)>span:nth-child(2){
		  position: relative;
		  float:left;
		  width: calc(100% - 40px);
		  text-align: left;
		  line-height: 36px;  
		 font-size:13px;
		font-weight:500;
		color:rgba(102,102,102,1);
	}
	
	.danping{
		position: relative;
		float: left;
		width: 100%;
	}
	.danping>.danshi{
		position: relative;
		float: left;
		width: 100%;
		background: #FFFFFF;
		padding: 15px  0;
		border-bottom: 1px solid  rgba(235,235,235,1);
	}
	.danshi>div:nth-child(1){
		position: relative;
		float: left;
		width: 100%;
	    height: 40px;
	}
	.danshi>div:nth-child(2){
		position: relative;
		float: left;
		margin-top: 15px;
		width: 100%;
		font-size:14px;
	font-weight:500;
	color:rgba(102,102,102,1);
	line-height:22px;
	text-indent: 2em;
	}
	
	.danshi>div:nth-child(1)>div:nth-child(1){
		position: relative;
		float: left;
		width: 40px;
		height: 40px;
	}
	.danshi>div:nth-child(1)>div:nth-child(1)>img{
		width: 40px;
		height: 40px;
		border-radius: 50%;
	}
	.danshi>div:nth-child(1)>div:nth-child(2){
		position: relative;
		float: left;
		width: calc(100% - 40px);
		height: 40px;
		padding-left: 15px;
		box-sizing: border-box;
	}
	.danshi>div:nth-child(1)>div:nth-child(2)>div{
	position: relative;
		float: left;
		width: 100%;
		height: 20px;
		line-height: 20px;
		font-size:11px;
	font-weight:500;
	color:rgba(102,102,102,1);
	}
	.hufoot{
		position: fixed;
		width: 100%;
		height: 66px;
		padding: 13px  15px;
		background:rgba(252,252,252,1);
	    box-shadow:0px 5px 7px 0px rgba(239, 239, 239, 0.35);
		bottom: 0px;
	    z-index: 10;
	}
	
	.hufoot>input{
		position: relative;
		float: left;
		width:calc(100% - 95px);
		height: 40px;
		border:1px solid rgba(232,232,232,1);
	border-radius:4px;
	box-sizing: border-box;
	font-size:14px;
	font-weight:500;
	color:rgba(153,153,153,1);
	line-height:40px;
	
	}
	.hufoot>div{
		text-align: center;
		width: 80px;
		height: 40px;
		position: relative;
		float: right;
		line-height: 40px;
		font-size:14px;
	font-weight:bold;
	color:rgba(255,255,255,1);
	background:linear-gradient(84deg,rgba(252,126,119,1) 0%,rgba(254,96,93,1) 100%);
	border-radius:4px;
	}
	.shangp_one{
		width: 100%;
		position: relative;
		float: left;
		padding-left: 15px;
		box-sizing: border-box;
		border-bottom: 1px solid #F8F8F8;
		padding-bottom: 15px;
		padding-top: 15px;
	}
	.shangp_one>span{
		font-size:16px;
		font-family:PingFang-SC-Bold;
		font-weight:bold;
		color:rgba(51,51,51,1);
		
	}
	.shangp_one>input{
		width: 80%;
		border:none;
		position: relative;
		float: right;
		margin-top: -8px;
		margin-bottom: 0px; 
	}
	input::-webkit-input-placeholder { 
	text-align:right; 
	font-size:14px;
	font-family:PingFang-SC-Medium;
	font-weight:500;
	color:rgba(205,205,205,1);
}


  #mainimg{
	  position: relative;
	  max-height: 200px;
	  overflow: hidden;
  }
</style>
	<body>
	  <header class="mui-bar mui-bar-nav">
	  	<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	  	<h1 class="mui-title">发布上传</h1>
	  </header>
		<div class="mui-content">
			
			
		  <div class="shipin" id="shipin">
			<div><img  id="mainimg" src="../image/sshangchuan.png"  /></div>
			<div>添加商品主图</div>
			</div>
		
			
        <div  class="hang"></div>	
         <!-- 选择视频分类 -->				
			<div  class="fenlei">
				<div>商品分类分类</div>
				<select class="mui-btn mui-btn-block" id="fenlei">
					<option value="" style="display: none;">请选择视频分类></option>
					<!-- <option value="item-1">艺术类型</option>
					<option value="item-2">才艺展示</option>
					<option value="item-3">小品相声</option>
					<option value="item-4">歌声嘹亮</option>
					<option value="item-5">其他类型</option> -->
				</select>
			</div>
			
			
			
		<div  class="hang"></div>	
	
	      <div class="shangp_one">
			  <span>商品名称</span>
			  <input type="text" name="name" id="name" value="" placeholder="0/20" />
		  </div>
			<div class="shangp_one">
				<span>商品价格</span>
				<input type="number" name="icons" id="icons" value="" placeholder="请填写商品价格,注意单位为金币,包含运费"/>
			</div>
			<div class="shangp_one">
				<span>商品数量</span>
				<input type="number" name="shenyu" id="shenyu" value="" placeholder="请填写商品价格,注意单位为金币,包含运费"/>
			</div>
			<div class="shangp_one">
				<span>运费</span>
				<input type="number" name="yunfei" id="yunfei" value="" placeholder="注意这是退货时,返回的运费"/>
			</div>
		<textarea id="textarea" rows="5" placeholder="请简要描述你的商品"></textarea>
	
	     
	    <div class="tupian">
			
              <div  class="tupians">
             					
             	</div>
            <img class="shangchuan"  id="otherimg" src="../image/shangchuanddd.png" />		
		</div>
	
	 
	<div  class="huqueren"> <button type="button" class="mui-btnss">保存</button></div> 
	 
		  </div>
		  
		</div>
	</body>
<script src="../js/mui.min.js"></script>
<script  src="../js/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
	mui.plusReady(function(){
		var url = plus.storage.getItem('url');
		var user = plus.storage.getItem('user');
		user = JSON.parse(user);
		var web = plus.webview.currentWebview();
		var shangpingid = web.shangpingid;
		var  fengmianid="";   // 封面图
			   var  listid=[];
		// mui.alert(shangpingid)
		//获取商品分类
		mui.post(url+'/juyou/mycommodity/getfenlei',{token:user.token,shangpingid:shangpingid},function(res){
			if(res.code==200){
				var str = '';
				var shangping = res.data.shangping;
				mui.each(res.data.classes,function(i,v){
					if(v.id==shangping.fenlei){
						str+='<option value="'+v.id+'" selected="selected">'+v.name+'</option>';
					}else{
						str+='<option value="'+v.id+'">'+v.name+'</option>';
					}
				})
				$("#fenlei").append(str);
				$("#mainimg").attr('src',shangping.zhanshi);
				$("[name=name]").val(shangping.name);
				$("[name=icons]").val(shangping.icons);
				$("[name=yunfei]").val(shangping.yunfei);
				$("[name=shenyu]").val(shangping.shenyu);
				$("#textarea").val(shangping.description);
				fengmianid = shangping.tupian;
				str = '';
				mui.each(shangping.lunbotu,function(i,v){
					str+="<div  class='imgdddd' ceshi='1'><img class='danimg'  src='"+v+"' /><img  ids='"+shangping.xiangqingtupian[i]+"'  class='danimg2' src='../image/fork.png'/></div>";
						
						listid.push(shangping.xiangqingtupian[i])
				})
				$(".tupians").append(str);
				// listid = 
			}else{
				mui.toast(res.msg);
			}
		})
		
		mui('.huqueren').on('tap','button',function(){
			var tupian = fengmianid;
			var xiangqingtupian = listid;
			if(!tupian){
				mui.toast('请上传封面图!');
				return
			}
			if(!tupian){
				mui.toast('请上传详情图!');
				return
			}
			var name = $("#name").val();
			if(!name){
				mui.toast('请填写名称!');
				return
			}
			var fenlei = $("#fenlei").val();
			if(!fenlei){
				mui.toast('请选择分类!');
				return
			}
			var icons = $("#icons").val();
			if(!icons){
				mui.toast('请输入价格!');
				return
			}
			var shenyu = $("#shenyu").val();
			if(!shenyu){
				mui.toast('请输入剩余数量');
				return
			}
			var yunfei = $("#yunfei").val();
			var description = $("#textarea").val();
			plus.nativeUI.showWaiting();
			mui.post(url+'/juyou/mycommodity/changeshangpin',{token:user.token,name:name,tupian:tupian,xiangqingtupian:xiangqingtupian,fenlei:fenlei,icons:icons,yunfei:yunfei,description:description,shangpingid:shangpingid,shenyu:shenyu,id:shangpingid},function(res){
				plus.nativeUI.closeWaiting();
				mui.toast(res.msg)
				if(res.code==200){
					setTimeout(function(){
						mui.back();
					},1500)
				}
			})
			
			
		})
		
		
		
		mui.init({
			beforeback: function() {　　　　
			var list = plus.webview.currentWebview().opener();　　　　
				  //refresh是A页面自定义事件
			mui.fire(list, 'refresh');
				 //返回true,继续页面关闭逻辑
			return true;
			},
		});
		
			   
			                   	/*点击添加商品主图触发*/
								document.getElementById('mainimg').addEventListener('tap', function() {
									if (mui.os.plus) {
										var a = [{
											title: "拍照"
										}, {
											title: "从手机相册选择"
										}];
										plus.nativeUI.actionSheet({
											title: "商品封面展示图",
											cancel: "取消",
											buttons: a
										}, function(b) { /*actionSheet 按钮点击事件*/
											switch (b.index) {
												case 0:
													break;
												case 1:
													getImages(function(data){
													
														$("#mainimg").attr("src",data.path);
														fengmianid=data.id;
													}); /*拍照*/
													break;
												case 2:
													galleryImages(function(data){
												
			                                             $("#mainimg").attr("src",data.path);
														 fengmianid=data.id;
													}); /*打开相册*/
													break;
												default:
													break;
											}
										})
									}
								}, false);
		
		
		                    // 点击添加商品图   //还要存储一个ID  
		                   document.getElementById('otherimg').addEventListener('tap', function() {
							   if(listid.length>=5){
								   mui.toast('商品详情最多上传5张图片');
								   return;
							   }
							   
							   
									if (mui.os.plus) {
										var a = [{
											title: "拍照"
										}, {
											title: "从手机相册选择"
										}];
										plus.nativeUI.actionSheet({
											title: "商品图",
											cancel: "取消",
											buttons: a
										}, function(b) { /*actionSheet 按钮点击事件*/
											switch (b.index) {
												case 0:
													break;
												case 1:
													getImages(function(data){
														console.log(data)
														// mui.alert(data.path)
														$(".danimg").attr("src",data.path)
													var 	str="";
													str+="<div  class='imgdddd' ceshi='1'><img class='danimg'  src='"+data.path+"' /><img  ids='"+data.id+"'  class='danimg2' src='../image/fork.png'/></div>"
														$(".tupians").append(str);
														listid.push(data.id)
													}); /*拍照*/
													break;
												case 2:
													galleryImages(function(data){
														console.log(data)
														// mui.alert(data.path)
															var str="";
			                                     	str+="<div  class='imgdddd' ceshi='2'><img class='danimg'  src='"+data.path+"' /><img  ids='"+data.id+"'  class='danimg2' src='../image/fork.png'/></div>"
			                                     	$(".tupians").append(str);
													listid.push(data.id)
													}); /*打开相册*/
													break;
												default:
													break;
											}
										})
									}
								}, false);
		
		  //点击删除照片
		  mui(document).on("tap",".danimg2",function(){
			var  ids=$(this).attr("ids");
			var index = listid.indexOf(ids);
			 listid.splice(index,1)   //移除id
		  var is=$(this).parent().closest(".imgdddd").css("display","none")
			})
			
			  //拍照
		  function getImages(func){
		      var mobileCamera=plus.camera.getCamera();
		      mobileCamera.captureImage(function(e){
		          plus.io.resolveLocalFileSystemURL(e,function(entry){
		              var path=entry.toLocalURL()+'?version='+new Date().getTime();
						 shangchuantouxiang(path,function(data){
							 if(func){
								 func(data)
							 }
						 })
		              // uploadHeadImg(path);
		          },function(err){
		              console.log("读取拍照文件错误");
		          });
		      },function(e){
		          console.log("er",err);
		      },function(){
		          filename:'_doc/head.png';
		      });
		  }
		
			   //从本地相册选择
		  function galleryImages(func){
		      console.log("你选择了从相册选择");
		      plus.gallery.pick(function(a){
		          plus.io.resolveLocalFileSystemURL(a,function(entry){
		              plus.io.resolveLocalFileSystemURL('_doc/',function(root){
		                  root.getFile('head.png',{},function(file){
		                      //文件已经存在
		                      file.remove(function(){
		                          entry.copyTo(root,'head.png',function(e){
		                              var path=e.fullPath+'?version='+new Date().getTime();
									     shangchuantouxiang(path,function(data){
											 if(func){
												 func(data)
												 
											 }
										 })
										// uploadHeadImg(path);
		                          },function(err){
		                              console.log("copy image fail: ",err);
		                          });
		                      },function(err){
		                          console.log("删除图片失败：（"+JSON.stringify(err)+")");
		                      });
		                  },function(err){
		                      //打开文件失败
		                      entry.copyTo(root,'head.png',function(e){
		                          var path=e.fullPath+'?version='+new Date().getTime();
		                          uploadHeadImg(path);
		                      },function(err){
		                          console.log("上传图片失败：（"+JSON.stringify(err)+")");
		                      });
		                  });
		              },function(e){
		                  console.log("读取文件夹失败：（"+JSON.stringify(err)+")");
		              });
		          });
		      },function(err){
		          console.log("读取拍照文件失败: ",err);
		      },{
		          filter:'image'
		      });
		  };
		     
		
		
		
		
		
		 // 上传视频封面图方法
		function  shangchuantouxiang(path,func){
			  plus.nativeUI.showWaiting();
			  var  image =new  Image();
			  image.src=path;
			  image.onload=function(){
				  	var imgData=getBase64Image(image); 
					  	mui.ajax(url+'/juyou/index/upimgs',{
					data:{
						file:imgData
					},
					dataType:'json',//服务器返回json格式数据
					type:'post',//HTTP请求类型
					timeout:10000,//超时时间设置为10秒；
					success:function(data){
							plus.nativeUI.closeWaiting()
							if(func){
								func(data)
							}
					},
					error:function(data){
						mui.alert("头像上传失败")
					}
				});  
			  }
		}
		
		
		
							  //压缩图片转成base64
		  function getBase64Image(img){
				// console.log(img.getBase64Image());
		      var canvas=document.createElement("canvas");
		      var width=img.width;
		      var height=img.height;
				var size = img.size;
		      if(width>height){
		          if(width>500){
		              height=Math.round(height*=500/width);
		              width=500;
		          }
		      }else{
		          if(height>500){
		              width=Math.round(width*=500/height);
		          }
		          height=500;
		      }
		
		      canvas.width=width;
		      canvas.height=height;
		      var ctx=canvas.getContext('2d');
		      ctx.drawImage(img,0,0,width,height);
		
		      var dataUrl=canvas.toDataURL('image/png',0.8);
		      return dataUrl.replace('data:image/png:base64,','');
		  } 
				
		
	})
			

      



		</script>
</html>